package com.ideaaedi.extspringcache.custom;


import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.lang.NonNull;

/**
 * redis序列化器定制器
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2023-05-31 11:58:33
 */
public interface ExtRedisSerializerCustomizer {
    
    /**
     * 定制redis key序列化器
     * <p>
     * 默认为：RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer(StandardCharsets.UTF_8));
     * </p>
     *
     * @return redis key序列化器
     *
     * @see RedisCacheConfiguration#serializeKeysWith(RedisSerializationContext.SerializationPair)
     */
    @NonNull
    RedisSerializationContext.SerializationPair<String> keySerializer();
    
    /**
     * 定制redis value序列化器
     * <p>
     * 默认为：RedisSerializationContext.SerializationPair.fromSerializer(new JdkSerializationRedisSerializer(classLoader))
     * </p>
     *
     * @return redis value序列化器
     *
     * @see RedisCacheConfiguration#serializeValuesWith(RedisSerializationContext.SerializationPair)
     */
    @NonNull
    RedisSerializationContext.SerializationPair<Object> valueSerializer();
}